package com.sunny.ihealth;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.View;

import com.sunny.ihealth.data.BmobManager;
import com.sunny.ihealth.data.PreferencesHelper;

/**
 * 基础fragment
 * Created by Sunny  An on 2016/5/31.
 */
public class BaseFragment extends Fragment {

    private static final String TAG = "TAG::BaseFragment";

    private BaseApplication application;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (getActivity() == null) {
            Log.e(TAG, "getActivity() == null   at  onAttach()");
            return;
        }
        application = ((BaseActivity) getActivity()).getBaseApp();
    }

    /**
     * 初始化view
     *
     * @param v view
     */
    public void initViews(View v) {

    }

    /**
     * 初始化数据
     */
    public void initData() {

    }


    public BmobManager getBmob() {
        return application.getBmob();
    }

    public PreferencesHelper getPreferencesHelper() {
        return application.getPreferencesHelper();
    }

    public String getCurrentUser() {
        return application.getCurrentUser();
    }
}
